{% extends "root/templates/base.html" %}

{% block content %}
<h2>Manage Permissions</h2>
<div class="info">
  Manage permissions for different users. Grant access to new users.
</div>

{% if user_permissions %}
<form method="post" action="/access/permissions/update">
<table>
  <tr>
    <th>Email</th>
    <th>Permissions</th>
  </tr>
  {% for user_permission in user_permissions %}
  <tr class="{% cycle alt1,alt2 %}">
    <td>{{ user_permission.user }}</a></td>
    <td>{% for permission in permissions %}
      <input type="checkbox" name="{{ user_permission.key }}"
        value="{{ permission.0 }}"
        {% if user_permission.permissions|has:permission.0 %}
          checked="checked"
        {% endif %} />
      {{ permission.1 }}&nbsp;&nbsp;
    {% endfor %}</td>
  </tr>
  {% endfor %}
</table>
<input type="submit" value="Update" />
</form>
{% endif %}

<div class="actions">
  <form method="post" action="/access/permissions/add">
    <fieldset><legend>Add New</legend>
      Email <input type="text" name="email" /><br />
      {% for permission in permissions %}
        <input type="checkbox" name="new_user" value="{{ permission.0 }}" />
        {{ permission.1 }}&nbsp;&nbsp;
      {% endfor %}
      <input type="submit" value="Create" />
    </fieldset>
  </form>
</div>

{% endblock %}
